package com.example.lending.Model.Dao;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.MediatorLiveData;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import com.example.lending.Model.User;

import java.util.List;

@Dao
public interface UserDao {
    @Insert
    void insertUser(User... users);

    @Update
    void updataUser(User... users);


    @Delete
    void deleteUser(User... users);

    @Query("delete from User")
    void deleteAllUser();

    @Query("select * from User order by id desc")
    LiveData<List<User>> getAllUserLive();

    @Query("select * from User where name like :pattern order by id desc")
    LiveData<List<User>>findUserWithPattern(String pattern);

    @Query("select * from User where name like :pattern order by id desc")
    List<User> findUsers(String pattern);
}
